{if $pid}
{template nheader.html}
<script type="text/javascript">
$(function() {
	{if $result}
	dr_tips("{$result}");
	{/if}
	dr_set_type('{$data.type}');
	$("#menu_body").sortable();
});
function dr_set_type(i) {
	$(".more").hide();
	$("#type_"+i).show();
	if (i == 'text') {
		$(".vvalue").hide();
	} else {
		$(".vvalue").show();
	}
}
</script>
<form class="form-horizontal" action="" method="post" id="myform" name="myform">
	<div class="page-bar">
		<ul class="page-breadcrumb mylink">
			{$menu.link}
			<li><a href="{SYS_HELP_URL}228.html" target="_blank"><i class="fa fa-book"></i> {fc_lang('在线帮助')}</a></li>
		</ul>
		<ul class="page-breadcrumb myname">
			{$menu.name}
		</ul>
		<div class="page-toolbar">
			<div class="btn-group pull-right">
				<button type="button" class="btn green btn-sm btn-outline dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> {fc_lang('操作菜单')}
					<i class="fa fa-angle-down"></i>
				</button>
				<ul class="dropdown-menu pull-right" role="menu">
					{loop $menu.quick $t}
					<li>
						<a href="{$t.url}">{$t.icon} {$t.name}</a>
					</li>
					{/loop}
					<li class="divider"> </li>
					<li>
						<a href="javascript:window.location.reload();">
							<i class="icon-refresh"></i> {fc_lang('刷新页面')}</a>
					</li>
				</ul>
			</div>
		</div>
	</div>
	<h3 class="page-title">
		<small>{fc_lang('商品属性是对商品信息的概括，方便买家快速筛选（文本输入类型不可参与搜索）')}</small>
	</h3>
	<div class="portlet light bordered myfbody">

		<div class="portlet-title">
			<div class="caption">
				<span class="caption-subject font-green">{fc_lang('商品属性')}</span>
			</div>
		</div>
		<div class="portlet-body">

			<div class="row">
				<div class="portlet-body form">

					{if $data.id}
					<div class="form-group">
						<label class="col-md-2 control-label">{fc_lang('分组')}：</label>
						<div class="col-md-9">
							<label><select name="data[pid]" class="form-control">
								{loop $group $n}
								<option {if $n.id == $data.pid} selected {/if} value="{$n.id}">{$n.name}</option>
								{/loop}
							</select></label>
						</div>
					</div>
					{/if}

					<div class="form-group">
						<label class="col-md-2 control-label">{fc_lang('类型')}：</label>
						<div class="col-md-9">
							<div class="radio-list">
								{loop $type $i $n}
								<label class="radio-inline"><input type="radio" name="data[type]" onclick="dr_set_type('{$i}')" value="{$i}" {if $data['type'] == $i}checked{/if} /> {$n}</label>
								{/loop}
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">{fc_lang('名称')}：</label>
						<div class="col-md-9">
							<label><input class="form-control" type="text" id="dr_name" onblur="d_topinyin('cname','name');" required  value="{$data.name}" name="data[name]"></label>

						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">{fc_lang('别名')}：</label>
						<div class="col-md-9">
							<label><input class="form-control" type="text" id="dr_cname"   value="{$data.cname}" name="data[cname]"></label>

						</div>
					</div>

					<div class="form-group vvalue">
						<label class="col-md-2 control-label">{fc_lang('选项值')}：</label>
						<div class="col-md-9">
							<div class="form-control-static">
								<label>选项值只能由字母或数字组成，请勿用特殊字符</label>
								<label><a class="btn green btn-xs" href="javascript:add_menu();"> <i class="fa fa-plus"></i> {fc_lang('添加')} </a></label>

							</div>
						</div>
					</div>
					<div class="form-group vvalue">
						<label class="col-md-2 control-label"></label>
						<div class="col-md-9">
							<ul id="menu_body" style="width:530px; overflow:hidden">
								{loop $data.value $t $v}
								<li>
									<table width="100%" class="menu-sort table_from">
										<tbody>
										<tr>
											<td  width="160"">{fc_lang('名称')}：<input class="input-text" type="text" name="value[name][]" value="{$v}" style="width:100px" /></td>
											<td align="left" width="160">{fc_lang('选项值')}：<input class="input-text" type="text" name="value[value][]" value="{$t}" style="width:100px" /></td>
											<td align="left"><a class="del" title="{lang('del')}" href="javascript:;" onClick="remove_menu(this)"></a></td>
										</tr>
										</tbody>
									</table>
								</li>
								{/loop}
							</ul>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">{fc_lang('是否搜索')}：</label>
						<div class="col-md-9">
							<div class="radio-list">
								<label class="radio-inline"><input type="radio" name="data[search]" value="1" {if $data['search']}checked{/if} /> {fc_lang('是')}</label>
								<label class="radio-inline"><input type="radio" name="data[search]" value="0" {if !$data['search']}checked{/if} /> {fc_lang('否')}</label>

							</div>
							<span class="help-block">{fc_lang('只对下拉和复选类型有效，文本类型不支持搜索')}</span>
						</div>
					</div>

				</div>
			</div>
		</div>
	</div>

	<div class="myfooter">
		<div class="row">
			<div class="portlet-body form">
				<div class="form-body">
					<div class="form-actions">
						<div class="row">
							<div class="col-md-12 text-center">
								<button type="submit" class="btn green"> <i class="fa fa-save"></i> {fc_lang('保存')}</button>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>


<script type="text/javascript">
    function add_menu() {
        var data = '<li><table width="100%" class="menu-sort ui-sortable "><tbody><tr><td width="160"><font color="red">*</font>&nbsp;{fc_lang('名称')}：<input class="input-text" type="text" name="value[name][]" value="" style="width:100px" /></td><td align="left" width="160">{fc_lang('选项值')}：<input class="input-text" type="text" name="value[value][]" style="width:100px" /></td><td align="left"><a class="del" title="{lang('del')}" href="javascript:;" onClick="remove_menu(this)"></a></td></tr></tbody></table></li>';
        $('#menu_body').append(data);
    }
    function remove_menu(_this) {
        $(_this).parent().parent().parent().remove();
    }
</script>
{template nfooter.html}
{else}
<script type="text/javascript">
$(function() { //防止回车提交表单
	document.onkeydown = function(e){ 
		var ev = document.all ? window.event : e;
		if (ev.keyCode==13) {
			$("#mark").val("1"); // 标识不能提交表单
		}
	}
	$(".table_form th").last().css('border','none');
	$(".table_form td").last().css('border','none');
});
function dr_form_check() {
	if ($("#dr_name").val() == '') {
		dr_form_tips('name', false, '{dr_lang("名称不能为空")}');
		return false;
	}
	if ($("#mark").val() == 0) { 
		return true;
	} else {
		return false;
	}
}
</script>
<div class="table-list" style="width:470px;">
<form action="" method="post" id="myform" name="myform" onsubmit="return dr_form_check()">
<input name="mark" id="mark" type="hidden" value="0" />
<table width="100%" class="table_form">
<tr>
    <th width="100"><font color="red">*</font>&nbsp;{fc_lang('分组名称')}： </th>
    <td>
    <input class="input-text" type="text" name="data[name]" value="{$data['name']}" size="40"/>

    </td>
</tr>
</table>
</form>
</div>
{/if}